package questions;

public class Question {
	private String question;
	private String awaitedAnswer;
	private String givenAnswer = null;
	private boolean used;
	
	public Question(String question, int numQuestion, String awaitedAnswer) {
		this.question = question;
		this.awaitedAnswer = awaitedAnswer;
	}

	public String getQuestion() {
		return question;
	}

	public void setQuestion(String question) {
		this.question = question;
	}

	public String getAwaitedAnswer() {
		return awaitedAnswer;
	}

	public void setAwaitedAnswer(String awaitedAnswer) {
		this.awaitedAnswer = awaitedAnswer;
	}

	public String getGivenAnswer() {
		return givenAnswer;
	}

	public void setGivenAnswer(String givenAnswer) {
		this.used = true;
		this.givenAnswer = givenAnswer;
	}

	public boolean isUsed() {
		return used;
	}

	public void setUsed(boolean used) throws IllegalStateException {
		if (this.givenAnswer.equals(null)) throw new IllegalStateException("No given answer");
		this.used = used;
	}
	
	public boolean isCorrect() {
		return awaitedAnswer.equals(givenAnswer);
	}
	
	public String toString() {
		return this.question + "? " + this.awaitedAnswer;
	}
	
}